package robocup.component.actions;

/**
 * PlayerTypeActions are used to assign heterogeneous player-types to the
 * players before simulation starts, or to exchange players during game. The
 * action can only be performed by the coach or the trainer, and the assignment
 * is further restricted:
 * <ul>
 * <li>Each heterogeneous player-type can only be assigned three times.
 * <li>Goalies can't be assigned to heterogeneous player types. These always
 * are of the default type (0).
 * <li>Exchanging during game can only be performed three times. Therefore, one
 * of the remaining possible assignments have to be used. This will refresh all
 * stamina-related attributes of the agent.
 * </ul>
 * 
 * Note that for a usage with the trainer, this command should be extended to
 * have a team as well.
 */
public class PlayerTypeAction
    extends Action {

  /**
   * The tricot number of the player, which should be assigned to a
   * heterogeneous player-type.
   */
  private int player = -1;

  /**
   * The id of the heterogeneous player type. These are given in the player
   * configurations send by the server.
   */
  private int type   = -1;

  /**
   * This class provides an action, which will change a player-type of a player
   * to one of the types sent by the server!
   */
  public PlayerTypeAction(
      final int player,
      final int type) {

    super();
    this.player = player;
    this.type = type;
  }

  /**
   * Returns the actions string representation:
   * 
   * @return (change_player_type &lt;player&gt; &lt;type&gt;)<br>
   *         <br>
   */
  @Override
  public String toString() {

    final StringBuffer buff = new StringBuffer();
    buff.append("(change_player_type ");
    buff.append(this.player);
    buff.append(' ');
    buff.append(this.type);
    buff.append(')');
    return buff.toString();
  }

}
